#ifndef __FIIPCLOUDVAR_H
#define __FIIPCLOUDVAR_H
#include <stdint.h>
#include "fiip-base/fiip.h"
#include "riselib/linkedList.h"
#include "riselib/varArray.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct CloudVar {
  uint8_t keyLen;
  uint8_t actualLen;
  uint8_t targetLen;
  uint8_t* keyVal;
  uint8_t* actualVal;
  uint8_t* targetVal;
} CloudVarStruct;
extern VarArrayStruct* fiipCloudVarLists;

void fiipCloudVar_init(void);
LinkedListStruct* fiipCloudVar_getVarList(uint8_t* id);
CloudVarStruct* fiipCloudVar_get(uint8_t* id, uint8_t* kVal, uint8_t kLen);
void fiipCloudVar_onActualChange(uint8_t* id,
                                 uint8_t* kVal,
                                 uint8_t kLen,
                                 void (*fun)(uint8_t* id, CloudVarStruct* var));
void fiipCloudVar_onTargetChange(uint8_t* id,
                                 uint8_t* kVal,
                                 uint8_t kLen,
                                 void (*fun)(uint8_t* id, CloudVarStruct* var));
void fiipCloudVar_setActual(uint8_t* id,
                            uint8_t* kVal,
                            uint8_t kLen,
                            uint8_t* vVal,
                            uint8_t vLen);
void fiipCloudVar_setTarget(uint8_t* id,
                            uint8_t* kVal,
                            uint8_t kLen,
                            uint8_t* vVal,
                            uint8_t vLen);
uint8_t fiipCloudVar_getActual(uint8_t* id,
                               uint8_t* kVal,
                               uint8_t kLen,
                               uint8_t* vVal);
uint8_t fiipCloudVar_getTarget(uint8_t* id,
                               uint8_t* kVal,
                               uint8_t kLen,
                               uint8_t* vVal);

#ifdef __cplusplus
}
#endif
#endif  //__FIIPCLOUDVAR_H
